package ru.jexp.rcp.supply.beans.commands;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

public class OpenViewHandler extends SelectionAdapter
{
	private final IWorkbenchPartSite site;
	private final String idView;

	public OpenViewHandler(IWorkbenchPartSite site, String idView, String nameView)
	{
		this.site = site;
		this.idView = idView;
	}

	@Override
	public void widgetSelected(SelectionEvent e)
	{
		IWorkbenchWindow window = site.getWorkbenchWindow();
		IWorkbenchPage page = window.getActivePage();
		try
		{
			page.showView(idView);
		}
		catch (PartInitException e1)
		{
			e1.printStackTrace();
		}
	}
}
